package com.smartStatus.admin.utils;

import com.smartStatus.api.autha.SysUserDetails;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Component;

/**
 * @ClassName : SysUserSecurity
 * @Author : lby
 * @Date: 2021/4/24 11:11
 * @Description : 当前登录人
 */
@Component
public class SysUserSecurity {
    /**
     * 当前登录人
     *
     * @return
     */
    public static String getUser() {
        SecurityContext context = SecurityContextHolder.getContext();
        SysUserDetails sysUser = (SysUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        return sysUser.getUserId();
    }
}
